package ch.bfh.swos.learnaid.rest.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;

import ch.bfh.swos.learnaid.model.Question;
import ch.bfh.swos.learnaid.rest.gcm.GCMSender;
import ch.bfh.swos.learnaid.service.dto.AnswerDTO;
import ch.bfh.swos.learnaid.service.dto.QListDTO;
import ch.bfh.swos.learnaid.service.dto.QuestionDTO;

@Controller
@RequestMapping("/sender")
public class GCMSenderController {
    
    @RequestMapping(value = "{id}", method = RequestMethod.PUT)
    @ResponseBody
    public void send(@RequestBody QListDTO qlist, @PathVariable long id) {
               
        Gson gson = new Gson();
        String out =  gson.toJson(qlist);
        System.out.println(out);
        new GCMSender().sendMessage(out);
    }
    
}
